//
//  ZDTabBarController.m
//  ZHIDOU
//
//  Created by 向礼 on 2018/12/18.
//  Copyright © 2018 向礼. All rights reserved.
//

#import "ZDTabBarController.h"
#import "ZDTabBar.h"
#import "FLBNavgationController.h"

#import "MyCourseViewController.h"
#import "PracticeViewController.h"
#import "MyViewController.h"

@interface ZDTabBarController ()

@end

@implementation ZDTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addCustomTabBar];
    [self AddChildViewController];
    // Do any additional setup after loading the view.
}

- (void)addCustomTabBar
{
    ZDTabBar *customTabBar = [[ZDTabBar alloc] init]; // 创建自定义tabbar
  
    
    [self setValue:customTabBar forKeyPath:@"tabBar"];  // 更换系统自带的tabbar
}

-(void)AddChildViewController{
    //HomePageViewController *home = [[HomePageViewController alloc]init];
    MyCourseViewController *course = [[MyCourseViewController alloc]init];
    PracticeViewController *Practice = [[PracticeViewController alloc] initWithNibName:@"PracticeViewController" bundle:nil];
    MyViewController *my= [[MyViewController alloc]init];
    
    NSArray *childArr = @[course,Practice,my];
    
    
//    HomePageViewController *home = [[MCHomeViewController alloc] initWithNibName:@"MCHomeViewController" bundle:nil];
//    FLBFinancViewController * financ = [[FLBFinancViewController alloc]init];
//    MCDiscoverViewController *discover=[[MCDiscoverViewController alloc] init];
//    FLBMyViewController *my=[[FLBMyViewController alloc]init];
//
//    NSArray *childArr = @[home,financ,discover,my];
//
    NSArray * normalImages = @[@"tab_class_normal",
                               @"tab_practice_normal",
                               @"tab_my_normal"];

    NSArray * selectedImages = @[@"tab_class_selected",
                                 @"tab_practice_selected",
                                 @"tab_my_selected"];
    NSArray * titleArr = @[@"课程",@"练习",@"我的"];
    for (int i = 0; i < childArr.count; i ++) {
        UIViewController *childVC=childArr[i];
        childVC.navigationItem.title = titleArr[i];
        childVC.tabBarItem.title= @"";
        childVC.tabBarItem.image = [[UIImage imageNamed:normalImages[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImages[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        FLBNavgationController *nav = [[FLBNavgationController alloc] initWithRootViewController:childVC];
        [self addChildViewController:nav];
    }
}


@end
